import { createStore, applyMiddleware, Store, AnyAction } from "redux";
import reducers, { CombinedState } from "../src/store/reducers";

interface Ext {
  persist: string;
}
interface StateExt {
  router: string;
}
type NewCombinedState = CombinedState & StateExt;

function storeEnhancer<Ext, StateExt>() {
  return (createStore: any) => (reducer: any, enhancer: any) => {
    var store = createStore(reducer, enhancer);
    return {
      ...store,
      persist: "persist",
    };
  };
}

let store: Store<NewCombinedState, AnyAction> & Ext = createStore<
  CombinedState,
  AnyAction,
  Ext,
  StateExt
>(reducers, storeEnhancer<Ext, StateExt>());

console.log(store.persist);
console.log(store.getState().router);

export default store;
